package com.springbootblog.controller.fontend.thread;

public class TestField implements Runnable
{
    @Override
    public void run()
    {
        String name = Thread.currentThread().getName();
        System.out.println( name + " Runnable is running ! ");
        // 线程礼让，不一定礼让成功
        Thread.yield();
        System.out.println( name + " Runnable is stop ! ");
    }

    public static void main(String[] args)
    {
        TestField testField = new TestField();
        // 运行两个线程，如果不礼让，则是依次执行run和stop，礼让了就有可能是两个run再接两个stop
        new Thread(testField,"1").start();
        new Thread(testField,"2").start();
    }
}

